import Cookies from 'js-cookie';
import config from '@/config'

const { cookieExpires } = config;
const TOKEN_KEY = "token"; //这个是cookie的key

export const setToken = token => {
  Cookies.set(TOKEN_KEY,token,{ expires:cookieExpires || 1 });
};

export const getToken = () => {
  let token = Cookies.get(TOKEN_KEY);

  if(token){
    token = "Bearer " + token;
    return token;
  }

  else return null;
};